summary(data[,c("frlunch","efficacy","mathpost","anxiety.cgm","mathpre","male")])
# set ranges (nodes) for pseudo-imputations
nodes.frlunch <- c(0,1)
nodes.efficacy <- seq(1, 6, by = 1)
nodes.anxiety <- seq(-30, 30, by = 1)
nodes.mathpost <- seq(25, 95, by = 1)
# model for anxiety predictor: f(anxiety|mathpre,male)
model.anxiety <- list( "model"="linreg", "formula" = anxiety.cgm ~ mathpre + male, nodes = nodes.anxiety)
# model for mathpost outcome: f(mathpost|anxiety,anxiety^2,mathpre,male)
model.mathpost <- list("model" = "linreg", "formula" = mathpost ~ anxiety.cgm + I(anxiety.cgm^2) + mathpre + male, nodes = nodes.mathpost)
# model for efficacy auxiliary variable: f(efficacy|mathpost,anxiety,mathpre,male)
model.efficacy <- list("model" = "linreg", "formula" = efficacy ~ mathpost + anxiety.cgm + mathpre + male, nodes = nodes.efficacy)
# model for frlunch auxiliary variable: f(frlunch|efficacy,mathpost,anxiety,mathpre,male)
model.frlunch <- list("model" = "logistic", "formula" = frlunch ~ efficacy + mathpost + anxiety.cgm + mathpre + male, nodes = nodes.frlunch)
# combine predictor models into a list
predictor.models <- list(anxiety = model.anxiety, mathpost = model.mathpost, efficacy = model.efficacy)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.frlunch, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(lavaan)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat")
names(imps) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
data <- read.table("../data/behaviorachievement.dat")
names(data) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat")
names(data) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read2","stanread7","read9grp","behsymp1","lrnprob1","read1")])
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read2","stanread7","read9grp","behsymp1","lrnprob1","read1")])
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read2","stanread7","read9grp","behsymp1","lrnprob1","read1")])
# set ranges (nodes) for pseudo-imputations
nodes.read1 <- seq(30, 160, by = 2)
nodes.lrnprob1 <- seq(20, 100, by = 2)
nodes.behsymp1 <- seq(10, 100, by = 2)
nodes.read9grp <- c(0,1)
nodes.stanread7 <- seq(80, 420, by = 5)
nodes.read2 <- seq(10, 160, by = 2)
# model for male predictor: f(read1)
model.read1 <- list( "model" = "linreg", "formula" = read1 ~ 1, nodes = nodes.read1)
# model for lrnprob1 predictor: f(lrnprob1|read1)
model.lrnprob1 <- list( "model" = "linreg", "formula" = lrnprob1 ~ read1, nodes = nodes.lrnprob1)
# model for behsymp1 predictor: f(behsymp1|lrnprob1,read1)
model.behsymp1 <- list( "model" = "linreg", "formula" = behsymp1 ~ lrnprob1 + read1, nodes = nodes.behsymp1)
# model for behsymp1 predictor: f(read9grp|behsymp1,lrnprob1,read1)
model.read9grp <- list( "model" = "logistic", "formula" = read9grp ~ behsymp1 + lrnprob1 + read1, nodes = nodes.read9grp)
# model for stanread7 auxiliary variable f(stanread7|read9grp,behsymp1,lrnprob1,read1)
model.stanread7 <- list("model" = "linreg", "formula" = stanread7 ~ read9grp + behsymp1 + lrnprob1 + read1, nodes = nodes.stanread7)
# model for stanread7 auxiliary variable f(read2|stanread7,read9grp,behsymp1,lrnprob1,read1)
model.read2 <- list("model" = "linreg", "formula" = read2 ~ stanread7 + read9grp + behsymp1 + lrnprob1 + read1, nodes = nodes.read2)
# combine predictor models into a list
predictor.models <- list(stanread7 = model.stanread7, read9grp = model.read9grp, behsymp1 = model.behsymp1, lrnprob1 = model.lrnprob1, read1 = model.read1)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.read2, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read9grp","behsymp1","lrnprob1","read1")])
# set ranges (nodes) for pseudo-imputations
nodes.read1 <- seq(30, 160, by = 2)
nodes.lrnprob1 <- seq(20, 100, by = 2)
nodes.behsymp1 <- seq(10, 100, by = 2)
nodes.read9grp <- c(0,1)
# model for male predictor: f(read1)
model.read1 <- list( "model" = "linreg", "formula" = read1 ~ 1, nodes = nodes.read1)
# model for lrnprob1 predictor: f(lrnprob1|read1)
model.lrnprob1 <- list( "model" = "linreg", "formula" = lrnprob1 ~ read1, nodes = nodes.lrnprob1)
# model for behsymp1 predictor: f(behsymp1|lrnprob1,read1)
model.behsymp1 <- list( "model" = "linreg", "formula" = behsymp1 ~ lrnprob1 + read1, nodes = nodes.behsymp1)
# model for read9grp outcome: f(read9grp|behsymp1,lrnprob1,read1)
model.read9grp <- list( "model" = "logistic", "formula" = read9grp ~ behsymp1 + lrnprob1 + read1, nodes = nodes.read9grp)
# combine predictor models into a list
predictor.models <- list(behsymp1 = model.behsymp1, lrnprob1 = model.lrnprob1, read1 = model.read1)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.read9grp, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read9grp","read1","lrnprob1","behsymp1")])
# set ranges (nodes) for pseudo-imputations
nodes.read9grp <- c(0,1)
nodes.read1 <- seq(30, 160, by = 2)
nodes.lrnprob1 <- seq(20, 100, by = 2)
nodes.behsymp1 <- seq(10, 100, by = 2)
# model for rea predictor: f(behsymp1)
model.behsymp1 <- list( "model" = "linreg", "formula" = behsymp1 ~ 1, nodes = nodes.behsymp1)
# model for lrnprob1 predictor: f(lrnprob1|read1)
model.lrnprob1 <- list( "model" = "linreg", "formula" = lrnprob1 ~ behsymp1, nodes = nodes.lrnprob1)
# model for read1 predictor: f(behsymp1|lrnprob1,read1)
model.read1 <- list( "model" = "linreg", "formula" = read1 ~ lrnprob1 + behsymp1, nodes = nodes.read1)
# model for read9grp outcome: f(read9grp|behsymp1,lrnprob1,read1)
model.read9grp <- list( "model" = "logistic", "formula" = read9grp ~ read1 + lrnprob1 + lrnprob1, nodes = nodes.read9grp)
# combine predictor models into a list
predictor.models <- list(behsymp1 = model.behsymp1, lrnprob1 = model.lrnprob1, read1 = model.read1)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.read9grp, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read imputed data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("read9grp","read1","lrnprob1","behsymp1")])
# set ranges (nodes) for pseudo-imputations
nodes.read9grp <- c(0,1)
nodes.read1 <- seq(30, 160, by = 2)
nodes.lrnprob1 <- seq(20, 100, by = 2)
nodes.behsymp1 <- seq(10, 100, by = 2)
# model for rea predictor: f(behsymp1)
model.behsymp1 <- list( "model" = "linreg", "formula" = behsymp1 ~ 1, nodes = nodes.behsymp1)
# model for lrnprob1 predictor: f(lrnprob1|read1)
model.lrnprob1 <- list( "model" = "linreg", "formula" = lrnprob1 ~ behsymp1, nodes = nodes.lrnprob1)
# model for read1 predictor: f(behsymp1|lrnprob1,read1)
model.read1 <- list( "model" = "linreg", "formula" = read1 ~ lrnprob1 + behsymp1, nodes = nodes.read1)
# model for read9grp outcome: f(read9grp|behsymp1,lrnprob1,read1)
model.read9grp <- list( "model" = "logistic", "formula" = read9grp ~ read1 + lrnprob1 + behsymp1, nodes = nodes.read9grp)
# combine predictor models into a list
predictor.models <- list(behsymp1 = model.behsymp1, lrnprob1 = model.lrnprob1, read1 = model.read1)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.read9grp, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read imputed data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# summarize incomplete predictors to determine ranges for pseudo-imputations
summary(data[,c("stanread7","read2","read9grp","read1","lrnprob1","behsymp1")])
# set ranges (nodes) for pseudo-imputations
nodes.read9grp <- c(0,1)
nodes.read1 <- seq(30, 160, by = 2)
nodes.lrnprob1 <- seq(20, 100, by = 2)
nodes.behsymp1 <- seq(10, 100, by = 2)
nodes.read2 <- seq(10, 160, by = 2)
nodes.stanread7 <- seq(80, 420, by = 5)
# model for behsymp1 predictor: f(behsymp1)
model.behsymp1 <- list( "model" = "linreg", "formula" = behsymp1 ~ 1, nodes = nodes.behsymp1)
# model for lrnprob1 predictor: f(lrnprob1|behsymp1)
model.lrnprob1 <- list( "model" = "linreg", "formula" = lrnprob1 ~ behsymp1, nodes = nodes.lrnprob1)
# model for read1 predictor: f(read1|lrnprob1,behsymp1)
model.read1 <- list( "model" = "linreg", "formula" = read1 ~ lrnprob1 + behsymp1, nodes = nodes.read1)
# model for read9grp outcome: f(read9grp|read1,lrnprob1,behsymp1)
model.read9grp <- list( "model" = "logistic", "formula" = read9grp ~ read1 + lrnprob1 + behsymp1, nodes = nodes.read9grp)
# model for read2 auxiliary variable f(read2|read9grp,read1,lrnprob1,behsymp1)
model.read2 <- list("model" = "linreg", "formula" = read2 ~ read9grp + read1 + lrnprob1 + behsymp1, nodes = nodes.read2)
# model for stanread7 auxiliary variable f(stanread7|read2,read9grp,read1,lrnprob1,behsymp1)
model.stanread7 <- list("model" = "linreg", "formula" = stanread7 ~ read2 + read9grp + read1 + lrnprob1 + behsymp1, nodes = nodes.stanread7)
# combine predictor models into a list
predictor.models <- list(read2 = model.read2, read9grp = model.read9grp, behsymp1 = model.behsymp1, lrnprob1 = model.lrnprob1, read1 = model.read1)
# estimate factored regression model w mdmb
fit <- frm_em(dat = data, dep = model.stanread7, ind = predictor.models)
summary(fit)
# example x:logistic regression with fiml estimation
library(fdir)
library(mdmb)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# specify model with labels
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
# estimate model in lavaan
fit <- sem(model, data, fixed.x = F, missing = "fiml")
# example x:logistic regression with fiml estimation
library(fdir)
library(lavaan)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# specify model with labels
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
# estimate model in lavaan
fit <- sem(model, data, fixed.x = F, missing = "fiml")
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
table(data$male, data$hispanic)
table(data$male)
table(data$male, data$hispanic)
# example x:logistic regression with fiml estimation
library(fdir)
library(lavaan)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# specify model with labels
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
# estimate model in lavaan
fit <- sem(model, data, fixed.x = F, missing = "fiml")
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
# example x:linear regression with fiml estimation with auxiliary variables
library(fdir)
library(lavaan)
library(semTools)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("../data/behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# specify model with labels
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
# estimate model in lavaan
fit <- sem.auxiliary(model, data, fixed.x = F, aux = c("hispanic","read2","stanread7"))
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
# example 1:linear regression with fiml estimation and auxiliary variables
library(fdir)
library(lavaan)
library(semTools)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","atriskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# specify model with labels
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
# estimate model in lavaan
fit <- sem.auxiliary(model, data, fixed.x = F, aux = c("hispanic","read2","stanread7"))
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
# example x:linear regression with fiml estimation
library(fdir)
library(lavaan)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","riskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem(model, data, fixed.x = F, missing = "fiml")
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
# example 1:linear regression with fiml estimation and auxiliary variables
library(fdir)
library(lavaan)
library(semTools)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","riskgrp","atrisk","behsymp1","schprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem.auxiliary(model, data, fixed.x = F, aux = c("hispanic","read2","stanread7"))
# example 1:linear regression with fiml estimation and auxiliary variables
library(fdir)
library(lavaan)
library(semTools)
##################################################
# read data
##################################################
# set working directory
set()
# read raw data from working directory
data <- read.table("behaviorachievement.dat", na.strings = "999")
names(data) <- c("id","male","hispanic","riskgrp","atrisk","behsymp1","lrnprob1",
"read1","read2","read3","read9","read9grp","stanread7",
"math1","math2","math3","math9","math9grp","stanmath7")
##################################################
# analysis
##################################################
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem.auxiliary(model, data, fixed.x = F, aux = c("hispanic","read2","stanread7"))
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
library(lavaan)
data_url <- "https://raw.githubusercontent.com/craigenders/ies-toolkit/main/Data/mathachievement.rda"
load(gzcon(url(data_url, open = "rb")))
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem(model, behaviorachievement, fixed.x = F, missing = "fiml")
inspect(fit, "patterns")
inspect(fit, "coverage")
summary(fit, rsquare = T, standardize = T)
library(lavaan)
data_url <- "https://raw.githubusercontent.com/craigenders/ies-toolkit/main/Data/behaviorachievement.rda"
load(gzcon(url(data_url, open = "rb")))
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem(model, behaviorachievement, fixed.x = F, missing = "fiml")
inspect(fit, "patterns")
data_url <- "https://raw.githubusercontent.com/craigenders/ies-toolkit/main/Data/behaviorachievement.rda"
load(gzcon(url(data_url, open = "rb")))
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem(model, behaviorachievement, fixed.x = F, missing = "fiml")
inspect(fit, "patterns")
inspect(fit, "coverage")
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
lavTestWald(fit, constraints = wald.constraints)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
inspect(fit, "coverage")
library(fdir)
library(lavaan)
library(semTools)
install.packages("fdir")
library(lavaan)
library(semTools)
data_url <- "https://raw.githubusercontent.com/craigenders/ies-toolkit/main/Data/behaviorachievement.rda"
load(gzcon(url(data_url, open = "rb")))
# estimate model in lavaan
model <- 'read9 ~ b1*read1 + b2*lrnprob1 + b3*behsymp1'
fit <- sem.auxiliary(model, behaviorachievement, fixed.x = F, aux = c("hispanic","read2","stanread7"))
summary(fit, rsquare = T, standardize = T)
# missing data patterns and proportion observed data (coverage)
inspect(fit, "patterns")
inspect(fit, "coverage")
summary(fit, rsquare = T, standardize = T)
# wald test that all slopes equal 0
wald.constraints <- 'b1 == 0; b2 == 0; b3 == 0;'
lavTestWald(fit, constraints = wald.constraints)
